/* 用户管理 */
import Vue from "vue";

const state = {
    roleList: []
};

const getters = {
    GET_ROLELIST: state => state.roleList
};

const mutations = {
    /* 用于存储任意键值对: { key: 键名, value: 值 } */
    SET_COMMON: (state, obj) => {
        state[obj.key] = obj.value;
    }
};

const actions = {
    /* 获取全部角色列表 */
    getRoleList ({ commit, state, dispatch }) {
        const params = {
            roleName: "",
            page: 1,
            pageSize: 9999
        };
        Vue.prototype.$request.post(Vue.prototype.API.GET_ROLE_LIST, params).then(res => {
            if (res.success) {
                commit("SET_COMMON", { key: "roleList", value: res.data.data });
            }
        });
    }
};

export default {
    namespaced: true,
    state,
    mutations,
    actions,
    getters
};